public class Demo6 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 2; i++) {
                System.out.println("hello t1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

            System.out.println("t1 结束");
        });

        Thread t2 = new Thread(() -> {
            System.out.println("t2 开始等待");
            /*try {
                t1.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }*/
            for (int i = 0; i < 2; i++) {
                System.out.println("hello t2");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }

            System.out.println("t2 结束");
        });
        t1.start();
        t2.start();
        System.out.println("main 开始等待");
        //t1.join();
        //t2.join();
        System.out.println("main 结束");
    }
}